<template>
  <div>
    <el-form ref="form" :model="admin" :rules="rules" label-width="80px">
      <el-form-item label="序号">
        <el-input v-model="admin.a_id" readonly="readonly"></el-input>
      </el-form-item>
      <el-form-item label="用户名" prop="a_username">
        <el-input v-model="admin.a_username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="a_password">
        <el-input v-model="admin.a_password"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    name: "AdminUpdate",
    data(){
      return{
        admin:{},
        rules:{},
      }
    },
    methods:{
      onSubmit(){
        this.$refs.form.validate(valid=>{
          if (valid){
            this.$axios.post('AdminServlet/update?a_username=' +this.admin.a_username +'&a_password=' + this.admin.a_password + '&a_id=' + this.admin.a_id)
              .then(resp=>{
                this.$router.push('/admin/list')
              })
          }
        })
      },

    },
    created() {
      this.$axios.get('AdminServlet/findById?a_id='+this.$route.params.id)
        .then(resp=>{
          this.admin = resp.data
        })
    }
  }
</script>

<style scoped>

</style>
